<template>
	<jk-view :loading="showLoading">
		<el-form ref="ruleForm" :model="ruleForm" :rules="rules" :hide-required-asterisk="pageType === 'detail'" label-width="90px" :show-message="false">
			<jk-operation-card class="margin-bottom-10 margin-top-10 width-100-percent fixed-operation-bar">
				<div class="flex-between-center">
					<div class="flex-start-center">
						<el-tag v-if="ruleForm.id" size="mini" type="info">
							<jk-state-bar :state="ruleForm.auditState" :state-list="auditStateList"></jk-state-bar>
						</el-tag>
					</div>
					<div class="flex-start-center">
						<el-button type="info" plain icon="el-icon-back" size="small" class="item-gap" @click="onJumpList">返回列表</el-button>
						<jk-button v-if="pageType !== 'detail'" icon="el-icon-finished" :loading="saveBtnLoading" type="primary" @click="onConfirmBtn">保存</jk-button>
					</div>
				</div>
			</jk-operation-card>
			<jk-card v-loading="refreshLoading" class="machine-table" style="overflow: auto;">
				<el-tag type="primary" effect="plain" class="margin-bottom-4">
					<span class="el-icon-tickets item-gap"></span>
					<span>基本信息</span>
				</el-tag>
				<jk-card ref="box1">
					<el-row class="flex-start-center-wrap">
						<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
							<el-form-item class="margin-bottom-10" label="区域" prop="workshopId">
								<span v-if="ruleForm.id" class="read-only-2">{{ ruleForm.workshopName }}</span>
								<jk-select v-else v-model="ruleForm.workshopId" :clearable="false" :option-list="workshopList" size="medium" class="width-100-percent" placeholder="区域" @change="onWorkshopChange"></jk-select>
							</el-form-item>
						</el-col>
						<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
							<el-form-item class="margin-bottom-10" label="日期" prop="belongDate">
								<span v-if="ruleForm.id" class="read-only-2">{{ ruleForm.belongDate }}</span>
								<jk-date-picker v-else v-model="ruleForm.belongDate" :clearable="false" type="date" size="medium" placeholder="日期" @change="onDateChange" />
							</el-form-item>
						</el-col>
						<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
							<el-form-item class="margin-bottom-10" label="班次" prop="shiftId">
								<span v-if="pageType === 'detail' || dataId" class="read-only-2">{{ ruleForm.shiftName }}</span>
								<el-select v-else v-model="ruleForm.shiftId" clearable placeholder="班次" class="width-100-percent" @change="onScheduleShiftChange">
									<el-option
										v-for="item in scheduleShiftList"
										:key="item.shiftId"
										:label="`${item.shiftName} (${item.beginTime} ~ ${item.endTime})`"
										:value="item.shiftId"
									></el-option>
								</el-select>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row class="flex-start-center-wrap">
						<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
							<el-form-item class="margin-bottom-10" label="班组" prop="scheduleGroupId">
								<span v-if="pageType === 'detail' || dataId" class="read-only-2">{{ ruleForm.scheduleGroupName }}</span>
								<jk-select v-else v-model="ruleForm.scheduleGroupId" :disabled="!ruleForm.shiftId" :option-list="groupList" size="medium" label-key-name="groupName" class="width-100-percent" placeholder="班组" @change="onGroupChange"></jk-select>
							</el-form-item>
						</el-col>
						<!--						<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">-->
						<!--							<el-form-item class="margin-bottom-10" label="统计员" prop="empId">-->
						<!--								<span v-if="pageType === 'detail'" class="read-only-2">{{ ruleForm.empName }}</span>-->
						<!--								<remote-search-emp-input-->
						<!--									v-else-->
						<!--									placeholder="统计员"-->
						<!--									only-key="empId"-->
						<!--									query-name="empName"-->
						<!--									:form-data="ruleForm"-->
						<!--									@on-select="onSelectEmpChange"-->
						<!--								></remote-search-emp-input>-->
						<!--							</el-form-item>-->
						<!--						</el-col>-->
						<el-col v-if="pageType !== 'detail'" :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
							<el-form-item class="margin-bottom-10">
								<el-button class="margin-bottom-4" :loading="refreshLoading" :disabled="!ruleForm.workshopId || !ruleForm.belongDate || !ruleForm.scheduleShiftId || !ruleForm.scheduleGroupId" size="small" type="primary" icon="el-icon-refresh" @click="onRefreshDataBtn">更新数据</el-button>
							</el-form-item>
						</el-col>
						<el-col :span="24">
							<el-form-item class="margin-bottom-0" label="备注">
								<el-input v-model="ruleForm.remark" :disabled="pageType === 'detail'" :rows="2" size="large" type="textarea" placeholder="" />
							</el-form-item>
						</el-col>
					</el-row>
				</jk-card>
				<div class="flex-between-center margin-bottom-4 machine-card-header margin-top-20">
					<el-tag class="" type="primary" effect="plain">
						<span class="el-icon-box item-gap"></span>
						<span>机台产量汇总</span>
					</el-tag>
					<div class="flex-end-center">
						<!--<el-button :disabled="!ruleForm.id" size="mini" icon="el-icon-printer" class="item-gap" @click="onReportBtn(1)"></el-button>-->
						<!--<jk-full-screen-button type="default" class-name="machine-table"></jk-full-screen-button>-->
					</div>
				</div>
				<machine-data
					:form-data="ruleForm"
					:page-type="pageType"
					:machine-data="ruleForm.machineList"
					:height="dialogTableHeight + 20"
					@on-update="onUpdateMachineData"
				></machine-data>
				<!-- <div class="flex-between-center margin-bottom-4 margin-top-20">
					<el-tag class="" type="primary" effect="plain">
						<span class="el-icon-user item-gap"></span>
						<span>人员工资汇总</span>
					</el-tag>
					<div class="flex-end-center">
						<emp-info-batch-push-wx
							:disabled="!ruleForm.id"
							:data-item="{
								...ruleForm,
								empList: ruleForm.empSalarySummaryVOList,
								belongDate: ruleForm.belongDate,
								scheduleShiftName: ruleForm.scheduleShiftName,
								scheduleGroupName: ruleForm.scheduleGroupName
							}"
						></emp-info-batch-push-wx>
						<el-button :disabled="!ruleForm.id" size="mini" icon="el-icon-printer" @click="onReportBtn(2)"></el-button>
					</div>
				</div>
				<jk-table
					ref="empTable"
					show-footer
					:stripe="false"
					:footer-method="footerMethod"
					border
					:data="ruleForm.empSalarySummaryVOList || []"
					class="margin-bottom-10"
				>
					<vxe-column title="姓名" align="left" field="empName" :width="120">
						<template slot-scope="scope">
							<emp-info-push-wx
								:data-item="{
									...scope.row,
									...ruleForm,
									empId: scope.row.empId, // 统计员的字段和员工的字段名冲突，所以要覆盖掉统计员的
									empName: scope.row.empName,
									machineList: scope.row.machineList, // 解决和ruleForm上的machineLis字段名冲突，所以要覆盖掉
									totalSalary: scope.row.totalSalary // 解决字段名冲突的问题
								}"
							></emp-info-push-wx>
						</template>
					</vxe-column>
					<vxe-column title="总产量(M)" align="right" field="allOutput" :width="100" />
					<vxe-column title="总产量(kg)" align="right" field="allQty" :width="100" />
					<vxe-column title="工序" align="left" field="empProcessList" :width="820">
						<template slot="header">
							<table-header :header="empHeader"></table-header>
						</template>
						<template slot-scope="scope">
							<table-body :header="empHeader" :data="scope.row.empProcessList || []"></table-body>
						</template>
					</vxe-column>
					<vxe-column title="补贴" align="right" field="subsidyMoney" :width="100">
						<template slot-scope="scope">
							<span v-if="pageType === 'detail'">{{ scope.row.subsidyMoney }}</span>
							<jk-number-input v-else v-model="scope.row.subsidyMoney" :min="-99999" size="mini" @change="onBtChange($event, scope)"></jk-number-input>
						</template>
					</vxe-column>
					<vxe-column title="工资合计" align="right" field="empTotalSalary" :width="100"></vxe-column>
				</jk-table> -->

				<!-- <el-tag class="margin-bottom-4 margin-top-10" type="primary" effect="plain">
					<span class="el-icon-postcard item-gap"></span>
					<span class="item-gap">岗位与人员明细</span>
					<span style="font-size: 13px;">({{ calTotalEmpNum(ruleForm.empPostList) }}人)</span>
				</el-tag>
				<jk-table :stripe="false" border :data="ruleForm.empPostList" class="margin-bottom-10">
					<vxe-column title="岗位" align="left" field="postName" :width="120">
						<template slot-scope="scope">
							<div>{{ `${scope.row.postName} (${scope.row.empSum || 0}人)` }}</div>
						</template>
					</vxe-column>
					<vxe-column title="人员" align="left" field="empNameListString" :width="660"></vxe-column>
				</jk-table> -->
			</jk-card>
		</el-form>
	</jk-view>
</template>

<script>
    import calHeight from '/src/mixins/cal-dialog-height';
    import checkboxMachineDialog from '../../../schedule/empMachine/components/checkbox-machine-dialog';
    import remoteSearchEmpInput from '../../../production/order/components/remote-search-emp-input';
    import { formatDate } from '../../../../utils/jk/jk-tool';
    import { workforcemanagementScheduleList } from '../../../../api/schedule/scheduling';
    import machineData from '../components/machine-data';
    import handlerCache from '../../../../mixins/handler-cache';
    import empInfoPushWx from '../../xsDailyGroupYieldNew/components/emp-info-push-wx';
    import empInfoBatchPushWx from '../../xsDailyGroupYieldNew/components/emp-info-batch-push-wx';
    import {
        productionGroupProductionSalaryGetData,
        productionGroupProductionSalaryCreate, productionGroupProductionSalaryGet,
        productionGroupProductionSalaryUpdate
    } from '../../../../api/production/frontGroupYieldStatistics';
    import { auditStateList } from '../../../../utils/jk/status-option-list';
    import { mathJsAdd } from '../../../../utils/jk/jk-cals';
    import tableBody from './table/body';
    import tableHeader from './table/header';
    import XEUtils from 'xe-utils';

    export default {
        components: {
            tableBody,
            tableHeader,
            empInfoBatchPushWx,
            empInfoPushWx,
            machineData,
            checkboxMachineDialog,
            remoteSearchEmpInput
        },
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            pageType: {
                type: String,
                default: ''
            }
        },
        mixins: [calHeight, handlerCache],
        data() {
            return {
                empHeader: [
                    { title: '工序', key: 'processName', width: '70px', align: 'left' },
                    { title: '工序产量(M)', key: 'empProcessOutput', width: '110px', align: 'right' },
                    { title: '工序产量(kg)', key: 'empProcessQty', width: '100px', align: 'right', isSlot: false },
                    { title: '工序工资', key: 'empProcessSalary', width: '100px', align: 'right', isSlot: false },
                    { title: '工序机台', key: 'machineListString', width: '100%', align: 'left', isSlot: false }
                ],
                empTableData: [],
                auditStateList: auditStateList,
                refreshLoading: false,
                dataId: null,
                groupList: [],
                workshopList: [],
                showDialog: false,
                showLoading: true,
                saveBtnLoading: false,
                ruleForm: {
                    id: null,
                    scheduleShiftId: null,
                    scheduleGroupId: null,
                    belongDate: '',
                    empId: null,
                    shiftId: null,
                    empName: '',
                    workshopId: null,
                    empSalarySummaryVOList: [],
                    machineList: [],
                    empPostList: []
                },
                rules: {
                    belongDate: [{ required: true, trigger: 'change' }],
                    scheduleGroupId: [{ required: true, trigger: 'change' }],
                    empId: [{ required: true, trigger: 'change' }],
                    shiftId: [{ required: true, trigger: 'change' }],
                    workshopId: [{ required: true, trigger: 'change' }]
                },
                scheduleShiftList: []
            };
        },
        methods: {
            footerMethod({ columns, data }) {
                return [
                    columns.map((column, columnIndex) => {
                        if (columnIndex === 0) {
                            return '合计:';
                        }
                        if (['allOutput', 'allQty', 'subsidyMoney', 'empTotalSalary'].includes(column.property)) {
                            return XEUtils.sum(data, column.property);
                        }
                        return null;
                    })
                ];
            },
            onBtChange(e, scope) {
                let empProcessSalary = 0;
                this.ruleForm.empSalarySummaryVOList.forEach((empItem) => {
                    if (empItem.empId === scope.row.empId) {
                        empProcessSalary = 0;
                        empItem.empProcessList.forEach(empProcessItem => {
                            empProcessSalary = mathJsAdd(empProcessItem.empProcessSalary, empProcessSalary || 0);
                        });
                        this.$set(empItem, 'empTotalSalary', mathJsAdd(empProcessSalary, e));
                    }
                });
                this.updateTableFooterData();
            },
            calEmpSalary() {
                let allOutput = 0;
                let allQty = 0;
                let empMachineSalary = 0;
                this.ruleForm.empSalarySummaryVOList.forEach(empItem => {
                    // 计算每个人员的总产量(M/KG)、工资
                    allOutput = 0;
                    allQty = 0;
                    empMachineSalary = 0;
                    this.ruleForm.machineList.forEach(machineItem => {
                        machineItem.empList.forEach(mEmpItem => {
                            if (empItem.empId === mEmpItem.empId) {
                                allOutput = mathJsAdd(mEmpItem.empMachineOutput || 0, allOutput);
                                allQty = mathJsAdd(mEmpItem.empMachineQty || 0, allQty);
                                allQty = mathJsAdd(mEmpItem.empMachineSalary || 0, empMachineSalary);
                            }
                        });
                    });
                    this.$set(empItem, 'allOutput', allOutput);
                    this.$set(empItem, 'allQty', allQty);
                    this.$set(empItem, 'empTotalSalary', mathJsAdd(empMachineSalary, empItem.subsidyMoney || 0));

                    // 计算每个人员的工序总产量(M/KG)、工资
                    let empProcessOutput = 0;
                    let empProcessQty = 0;
                    let empProcessSalary = 0;
                    empItem.empProcessList.forEach(empProcessItem => {
                        empProcessOutput = 0;
                        empProcessQty = 0;
                        empProcessSalary = 0;
                        this.ruleForm.machineList.forEach(machineItem => {
                            machineItem.empList.forEach(mEmpItem => {
                                if (empItem.empId === mEmpItem.empId && machineItem.processId === empProcessItem.processId) {
                                    empProcessOutput = mathJsAdd(mEmpItem.empMachineOutput || 0, empProcessOutput);
                                    empProcessQty = mathJsAdd(mEmpItem.empMachineQty || 0, empProcessQty);
                                    empProcessSalary = mathJsAdd(mEmpItem.empMachineSalary || 0, empProcessSalary);
                                }
                            });
                        });
                        this.$set(empProcessItem, 'empProcessOutput', empProcessOutput);
                        this.$set(empProcessItem, 'empProcessQty', empProcessQty);
                        this.$set(empProcessItem, 'empProcessSalary', empProcessSalary);
                    });
                });
                this.updateTableFooterData();
            },
            calTotalEmpNum(list) {
                let val = 0;
                list.forEach(x => {
                    val = mathJsAdd(val, x.empSum || 0);
                });
                return val;
            },
            onRefreshDataBtn() {
                this.refreshLoading = true;
                this.getScheduleGroupMachineData();
            },
            onReportBtn(type) {
                const routeUrl = this.$router.resolve({
                    name: 'printFrontMachineReport',
                    query: {
                        id: this.ruleForm.id,
                        printType: type
                    }
                });
                window.open(routeUrl.href, '_blank');
            },
            updateTableFooterData() {
                this.$refs.empTable.$refs.xTable.updateFooter();
            },
            onJumpList() {
                this.$store.dispatch('tagsView/delView', { path: this.$route.path });
                this.$toMainRouter({
                    name: 'FrontGroupYieldStatistics'
                });
            },
            onUpdateMachineData(data) {
                this.$set(this.ruleForm, 'machineList', data ? JSON.parse(JSON.stringify(data)) : []);
                this.calEmpSalary();
                this.updateTableFooterData();
            },
            onGroupChange(e) {
                this.$set(this.ruleForm, 'machineList', []);
                this.$set(this.ruleForm, 'empSalarySummaryVOList', []);
                if (e) {
                    this.getScheduleGroupMachineData();
                }
            },
            getScheduleGroupMachineData() {
                if (!this.ruleForm.workshopId || !this.ruleForm.belongDate || !this.ruleForm.scheduleShiftId || !this.ruleForm.scheduleGroupId) return false;
                this.refreshLoading = true;
                productionGroupProductionSalaryGetData({
                    workshopId: this.ruleForm.workshopId,
                    belongDate: this.ruleForm.belongDate,
                    scheduleShiftId: this.ruleForm.scheduleShiftId,
                    shiftId: this.ruleForm.shiftId,
                    scheduleGroupId: this.ruleForm.scheduleGroupId
                }).then(res => {
                    this.refreshLoading = false;
                    if (res.data.status === 200) {
                        this.$set(this.ruleForm, 'empPostList', res.data.res.empPostList ? res.data.res.empPostList.map(x => x) : []);
                        this.$set(this.ruleForm, 'machineList', res.data.res.machineList ? res.data.res.machineList.map(x => x) : []);
                        this.$set(this.ruleForm, 'empSalarySummaryVOList', res.data.res.empSalarySummaryVOList ? res.data.res.empSalarySummaryVOList.map(x => {
                            x.subsidyMoney = x.subsidyMoney || 0;
                            x.singleSalary = x.singleSalary || 0;
                            x.totalSalary = x.singleSalary;
                            return x;
                        }) : []);
                    }
                });
            },
            onWorkshopChange() {
                this.$set(this.ruleForm, 'scheduleGroupId', null);
                this.$set(this.ruleForm, 'scheduleId', null);
                this.$set(this.ruleForm, 'scheduleShiftId', null);
                this.$set(this.ruleForm, 'shiftId', null);
                this.$set(this.ruleForm, 'shiftName', null);
                this.$set(this.ruleForm, 'machineList', []);
                this.$set(this.ruleForm, 'empSalarySummaryVOList', []);
                this.groupList = [];
                this.scheduleShiftList = [];
                this.setWorkshopInfo(this.ruleForm.workshopId);
                this.getDateScheduleShiftOptionRequest();
            },
            onScheduleShiftChange(e) {
                this.$set(this.ruleForm, 'machineList', []);
                this.$set(this.ruleForm, 'empSalarySummaryVOList', []);
                this.groupList = [];
                let item = {};
                if (e) {
                    item = this.scheduleShiftList.find(x => x.shiftId === e);
                } else {
                    item = {
                        id: null,
                        shiftId: null,
                        shiftName: null,
                        scheduleId: null
                    };
                }
                this.groupList = item.scheduleGroupList;
                this.$set(this.ruleForm, 'scheduleGroupId', null);
                this.$set(this.ruleForm, 'scheduleId', item.scheduleId);
                this.$set(this.ruleForm, 'scheduleShiftId', item.id);
                this.$set(this.ruleForm, 'shiftId', item.shiftId);
                this.$set(this.ruleForm, 'shiftCode', item.shiftCode);
                this.$set(this.ruleForm, 'shiftName', item.shiftName);
                this.$set(this.ruleForm, 'scheduleShiftCode', item.shiftCode);
                this.$set(this.ruleForm, 'scheduleShiftName', item.shiftName);
            },
            onDateChange() {
                this.$set(this.ruleForm, 'scheduleGroupId', null);
                this.$set(this.ruleForm, 'scheduleShiftId', null);
                this.$set(this.ruleForm, 'shiftId', null);
                this.$set(this.ruleForm, 'shiftCode', null);
                this.$set(this.ruleForm, 'shiftName', null);
                this.$set(this.ruleForm, 'scheduleShiftCode', null);
                this.$set(this.ruleForm, 'scheduleShiftName', null);
                this.$set(this.ruleForm, 'prdReportMachineList', []);
                this.$set(this.ruleForm, 'machineList', []);
                this.$set(this.ruleForm, 'empSalarySummaryVOList', []);
                this.groupList = [];
                this.scheduleShiftList = [];
                this.getDateScheduleShiftOptionRequest();
            },
            getDateScheduleShiftOptionRequest() {
                if (this.ruleForm.workshopId && this.ruleForm.belongDate) {
                    return workforcemanagementScheduleList({
                        belongDate: [this.ruleForm.belongDate, this.ruleForm.belongDate],
                        workshopId: this.ruleForm.workshopId
                    }).then(res => {
                        if (res.data.status === 200) {
                            const resData = res.data.res;
                            if (resData && resData.length) {
                                this.scheduleShiftList = resData[0].scheduleShiftList;
                                if (this.ruleForm.id) {
                                    const item = this.scheduleShiftList.find(x => x.id === this.ruleForm.scheduleShiftId).scheduleGroupList || {};
                                    this.groupList = item;
                                }
                            }
                        }
                    });
                }
            },
            onSelectEmpChange(e) {
                if (e && Object.keys(e).length) {
                    this.$set(this.ruleForm, 'empId', e.id);
                    this.$set(this.ruleForm, 'empName', e.name);
                }
            },
            getParamData() {
                const params = JSON.parse(JSON.stringify(this.ruleForm));
                if (!this.dataId) delete params.id;
                const item = this.workshopList.find(x => x.id === params.workshopId) || {};
                params.workshopCode = item.code;
                params.workshopName = item.name;

                if (!this.dataId) {
                    const scheduleGroupItem = this.groupList.find(x => x.id === params.scheduleGroupId);
                    params.groupId = scheduleGroupItem.groupId;
                    params.scheduleGroupCode = scheduleGroupItem.groupCode;
                    params.scheduleGroupName = scheduleGroupItem.groupName;
                }
                return params;
            },
            createAndUpdateRequest() {
                const api = !this.dataId ? productionGroupProductionSalaryCreate : productionGroupProductionSalaryUpdate;
                this.saveBtnLoading = true;
                api(this.getParamData()).then(res => {
                    this.saveBtnLoading = false;
                    if (res.data.status === 200) {
                        if (!this.dataId) {
                            this.$tipsBar(this, 'save');
                            this.$store.dispatch('tagsView/delView', { path: this.$route.path });
                            this.$toOtherRouter({
                                name: 'editFrontGroupYield',
                                query: {
                                    id: res.data.res
                                }
                            });
                        } else {
                            this.$tipsBar(this, 'save');
                            this.getDependentData();
                        }
                    }
                });
            },
            onConfirmBtn() {
                this.$refs['ruleForm'].validate(valid => {
                    if (valid) {
                        this.createAndUpdateRequest();
                    } else {
                        this.$tipsBar(this, 'validator');
                    }
                });
            },
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                    this.$nextTick(() => {
                        this.$refs.ruleForm.resetFields();
                    });
                }
            },
            getDetailRequest() {
                return productionGroupProductionSalaryGet({ id: this.dataId }).then(res => {
                    if (res.data.status === 200) {
                        const resData = res.data.res || {};
                        resData.machineList = resData.machineList || [];
                        resData.machineList.forEach(x => {
                            x.empList = x.empList || [];
                            x.productList = x.productList || [];
                        });

                        resData.empSalarySummaryVOList = resData.empSalarySummaryVOList || [];
                        resData.empSalarySummaryVOList.forEach(x => {
                            x.empProcessList = x.empProcessList || [];
                        });
                        this.ruleForm = resData;
                    }
                });
            },
            setWorkshopInfo(id) {
                const workshopItem = this.workshopList.find(x => x.id === id) || {};
                this.$set(this.ruleForm, 'workshopId', workshopItem.id);
                this.$set(this.ruleForm, 'workshopCode', workshopItem.code);
                this.$set(this.ruleForm, 'workshopName', workshopItem.name);
            },
            async getDependentData() {
                this.showLoading = true;
                this.dataId = this.$route.query.id;
                this.workshopList = this.$store.state.user.userWorkshop.workshopList;
                if (!this.dataId) {
                    this.$set(this.ruleForm, 'belongDate', formatDate(Date.now()));
                    this.$set(this.ruleForm, 'empId', this.$store.state.user.empInfo.id);
                    this.$set(this.ruleForm, 'empName', this.$store.state.user.empInfo.name);
                    this.setWorkshopInfo(this.$route.query.workshopId ? Number(this.$route.query.workshopId) : this.$store.state.user.userWorkshop.defaultWorkshopId);
                }
                if (this.dataId) await this.getDetailRequest();
                await this.getDateScheduleShiftOptionRequest();
                this.showLoading = false;
            },
            clearCacheMethod() {
                Object.assign(this.$data, this.$options.data());
                this.$nextTick(() => {
                    this.$refs.ruleForm.clearValidate();
                    this.getDependentData();
                });
            }
        },
        mounted() {
            this.getDependentData();
        }
    };
</script>
<style scoped lang="scss">
</style>
